package com.cloud.DrugManagement.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author zhozixiong
 * @date 2023/02/10
 */
public enum OrderState {

    /**
     * 0 订单已提交给商家
     * 1 商家已接单
     * 2 交易已完成
     */
    NOT_SUBMITTED(0, "未提交"),
    SUBMITTED(1, "已提交"),
    DELIVERED(2, "已交货"),
    COMPLETE(3, "已完成");

    @EnumValue
    private Integer code;

    @JsonValue
    private String status;

    OrderState(Integer code, String status) {
        this.code = code;
        this.status = status;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getStatus() {
        return this.status;
    }

    @Override
    public String toString() {
        return status;
    }

    @JsonCreator
    public static OrderState getItem(Integer code) {
        for (OrderState status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}
